package com.example.springboot;

import jakarta.servlet.http.HttpServletRequest;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.resource.ResourceHttpRequestHandler;

import java.nio.file.Path;

@Component
public class NonStaticResourceHandler extends ResourceHttpRequestHandler {
    protected Resource getResource(HttpServletRequest request){
        final Path filePath = (Path) request.getAttribute("NON-STATIC-FILE");
        return new FileSystemResource(filePath);
    }
}

